import { Response, PageResponse } from '@/types/Common';
import { EnterprisePageRequest, EnterpriseInfo } from '@/types/Enterprise';
import axios from '../request';

export default {
  /**
   * 分页查询接口
   * @param {EnterprisePageRequest} body
   * @return {Promise<Response<PageResponse<EnterpriseInfo>>>}
   */
  page: async (body) => {
    const res = await axios.post('/Api/Company/getList', body);
    return res.data;
  },
  /**
   * 新增接口
   * @param {EnterpriseInfo} body
   * @return {Promise<Response<EnterpriseInfo>>}
   */
  add: async (body) => {
    const res = await axios.post('/Api/Company/add', body);
    return res.data;
  },
  /**
   * 详情接口
   * @param {number} id
   * @return {Promise<Response<EnterpriseDetail>>}
   */
  detail: async (id) => {
    const res = await axios.post('/Api/Company/detail', {
      company_id: id,
    });
    return res.data;
  },
  /**
   * 编辑接口
   * @param {EnterpriseInfo} body
   * @return {Promise<Response<EnterpriseInfo>>}
   */
  edit: async (companyId, body) => {
    const res = await axios.post(`/Api/Company/update?company_id=${companyId}`, body);
    return res.data;
  },
  /**
   * 删除接口
   * @param {number} id
   * @return {Promise<Response<EnterpriseInfo>>}
   */
  delete: async (id) => {
    const res = await axios.post('/Api/Company/delete', { id });
    return res.data;
  },
};
